package com.imooc.distributedemo.resume.spring;

import com.imooc.distributedemo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 3中常见的注入方式
 */
@Component
public class InjectDemo {


//    字段注入
    @Autowired
    private OrderService orderService;

    private final OrderService orderService1;

//    构造器注入
    @Autowired
    public InjectDemo(OrderService orderService1) {
        this.orderService1 = orderService1;
    }

//    setter注入
    private OrderService orderService2;

    @Autowired
    public void setBean(OrderService orderService2){
        this.orderService2 = orderService2;
    }
}




